#!/bin/sh

# configure node for distributed erlang with IPV6 support
if [ ! -z "$TUIST_USE_IPV6" ]; then
  export ERL_AFLAGS="-proto_dist inet6_tcp"
  export ECTO_IPV6="true"
fi

# interpret common truthy values the same way our Elixir helpers do
is_truthy() {
  case "$1" in
    1|true|TRUE|yes|YES)
      return 0
      ;;
    *)
      return 1
      ;;
  esac
}

HOSTED_FLAG="${TUIST_CLOUD_HOSTED:-${TUIST_HOSTED:-0}}"

if is_truthy "$HOSTED_FLAG"; then
  export DNS_CLUSTER_QUERY="${RENDER_DISCOVERY_SERVICE}"
  export RELEASE_DISTRIBUTION="name"
  export RELEASE_NODE="${RENDER_SERVICE_NAME}@${RENDER_INTERNAL_IP}"
fi
